import axios from "axios";

import hyRequest from '../../index'
import { IDataType } from '../../types'

import {BASE_URL} from '@/service/request/config'


export function getPageListData(url: string, queryInfo: any) {
  return hyRequest.post<IDataType>({
    url: url,
    data: queryInfo
  })
}

export function DownloadPageListData(url: string, queryInfo: any) {
  console.log('queryInfo', queryInfo)
  const download_url = BASE_URL +'/' + url;
  console.log('downloadurl:', download_url)
    return axios({
        url: download_url,
        method: 'get',
        params: queryInfo,
        responseType: 'arraybuffer',
    })

}


// url: /users/id
export function deletePageData(url: string) {
  return hyRequest.delete<IDataType>({
    url: url
  })
}

export function createPageData(url: string, newData: any) {
  return hyRequest.post<IDataType>({
    url: url,
    data: newData
  })
}

export function editPageData(url: string, editData: any) {
  return hyRequest.patch<IDataType>({
    url: url,
    data: editData
  })
}
